﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace EntityPractica.Models
{
    public class AlumnoContenedor : DbContext
    {
        public AlumnoContenedor() : base("DefaultConnection") 
        {
        }

        public DbSet<Alumno> Alumnos { get; set; }

        public void agregarAlumno(Alumno unAlumno)
        {
            Alumnos.Add(unAlumno);

            SaveChanges();
        }
        public void borrarAlumno(Alumno unAlumno)
        {
            int aux = 0;
            if (Alumnos != null)
            {
                foreach (Alumno alumno in Alumnos)
                {
                    if (alumno.Dni == unAlumno.Dni)
                    {
                        Alumnos.Remove(alumno);

                    }
                }
                
            }
            SaveChanges();
        }

        
    }
}